# Contributor: Taner Tas <taner76@gmail.com>
# Maintainer: Taner Tas <taner76@gmail.com>
pkgname=fs-uae
# Remember to upgrade fs-uae-launcher to same version of fs-uae
pkgver=3.1.66
pkgrel=2
pkgdesc="Amiga emulator."
url="https://fs-uae.net/"
arch="all !armhf !armv7 !aarch64 !s390x"  # --enable-jit not supported for these arches
license="GPL-2.0-only"
makedepends="zip sdl2-dev libpng-dev libx11-dev libxi-dev openal-soft-dev linux-headers libmpeg2-dev glib-dev"
subpackages="$pkgname-lang"
source="
	https://fs-uae.net/files/FS-UAE/Stable/$pkgver/fs-uae-$pkgver.tar.xz
	fix-musl.patch
	musl-1.2.3.patch
	"
options="!check"

build() {
	local _jitoptions=
	case "$CARCH" in
		ppc64le)
			_jitoptions="--disable-jit"
			export CFLAGS="$CFLAGS -g -O2 -U__ALTIVEC__"
			export CXXFLAGS="$CXXFLAGS -D__STRICT_ANSI__ -g -O2 -U__ALTIVEC__"
			;;
		riscv64)
			_jitoptions="--disable-jit"
			;;
	esac

	./configure \
		--build=$CBUILD \
		--prefix=/usr \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--localstatedir=/var \
		$_jitoptions \
		--enable-sdl2
	make
}

package() {
	make DESTDIR="$pkgdir" install
	rm -rf "$pkgdir"/usr/share/doc
}
sha512sums="
3d93c6481d4aebb21607fa6cd0716bb809a902a5e6e20cda97751f7878157a0737b80df1290c2e1cf4e13f1e9a824b750c52479cd05e56bff291be7471d167a1  fs-uae-3.1.66.tar.xz
66d7a62329f13357fd422c84cd3a61325723dcde62878d43ca3f4894141a05b99cd9351ae452f0aea9bde0b6cb750c68329af2d21e282fd3351ace36e40232f7  fix-musl.patch
1d3310b449137ae2fbf57be4c9617cedb3ca5fcd1c9c199793d0d084bca3d8d3ac76c513ccf4d293e4a086d389b65db0b2983a56c80c628b534a4bf1e79ca5d2  musl-1.2.3.patch
"
